<template>
	<view>
		<cu-custom id="nav" :isBack="true" :bgColor="'bg-black'" :backColor="'text-white'">
			<block slot="backText"><view class="text-white ">核销信息</view></block>
		</cu-custom>

		<view class="cu-list menu" v-if="writeInfo">
			<view class="cu-card article">
				<view  class="margin-lr radius12 shadow padding-sm margin-tb-sm bg-white"
					style="position: relative;" >
					<view class="flex justify-start ">
						<image :src="$isHttp(writeInfo.play.picture)" lazy-load
							style="width: 160rpx;height: 220rpx;border-radius: 10rpx;" mode="aspectFill"></image>
						<view class=" margin-left-sm" style="width: 520rpx;">
							<view class="flex justify-start margin-top-xs">
								<view class="text-bold theme_text_color">{{writeInfo.play.name}}</view>
								<!-- <view class="cu-tag bg-yellow  sm round margin-left-sm">标签666</view> -->
							</view>
							<view class="margin-top-sm">
								<view v-for="(item1,index1) in writeInfo.play.smallClasses" :key="index1" v-if="index1<6"
									class="cu-tag sm round" style="background-color: #797979;color: #fff;">
									{{item1.small_name}}
								</view>
							</view>
							<view class="margin-top-sm flex justify-start" style="color: #b2b1b6;">
								<view class="flex justify-start align-center">
									<text class="cuIcon-friendfill text-yellow"></text>
									<view class="text-sm margin-left-xs">{{writeInfo.play.sex_type}}</view>
								</view>
								<view class="flex justify-start align-center margin-left-sm">
									<text class="cuIcon-timefill text-yellow"></text>
									<view class="text-sm margin-left-xs">{{writeInfo.play.hour}}小时</view>
								</view>
								<view class="flex justify-start align-center margin-left-sm">
									<text class="cuIcon-selectionfill text-yellow"></text>
									<view class="text-sm margin-left-xs">{{writeInfo.play.difficulty}}</view>
								</view>
							</view>
							<view class="flex justify-between  margin-top-sm">
								<view class="flex align-end text-yellow">
									<view class="text-sm ">会员价¥</view>
									<view class="text-lg text-bold">{{writeInfo.play.member_price}}</view>
									<view class="text-sm ">/位</view>
									<view class="text-lg text-gray" style="text-decoration:line-through">{{writeInfo.play.price}}</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<view class="cu-list menu-avatar" v-if="writeInfo">
			<view class="cu-item">
				<view class="cu-avatar round lg" :style="'background-image:url('+$isHttp(writeInfo.user.avatarUrl)+')'"></view>
				<view class="content">
					<view class="text-grey">{{writeInfo.user.userName}}</view>
					<view class="text-gray text-sm flex">
						<view class="text-cut">
							{{writeInfo.user.gender===1?'男':'女'}}
						</view>
					</view>
				</view>
			</view>
			
			<view class="bg-white padding flex justify-start">
				<view class="">
					<view class="text-black">车队ID：<text class="text-bold">{{writeInfo.order.orderId}}</text></view>
					<view class="text-gray flex">
						<view class="">
							<text class="cuIcon-infofill text-red  margin-right-xs"></text>
							预约时间：<text class="text-bold">{{writeInfo.order.date}} {{writeInfo.order.week}} {{writeInfo.order.time}}</text>
						</view>
					</view>
				</view>
			</view>
			
			<view class="bg-white padding flex justify-start">
				<view class="">
					<view class="text-black"  v-if="Object.keys(writeInfo.room).length!==0">
						房间ID：<text class="text-bold margin-right-sm">{{writeInfo.room.roomId}}</text>
						房间名：<text class="text-bold margin-right-sm">{{writeInfo.room.roomName}}</text> 
						房间编号：<text class="text-bold margin-right-sm">{{writeInfo.room.roomNumber}}</text>
					</view>
					<view class="text-black" v-else>
						未选择房间
					</view>
				</view>
			</view>
			
			<view class="bg-white padding flex justify-start">
				<view class="">
					<view class="text-black">用户支付：<text class="text-bold">{{writeInfo.money}}元</text></view>
					<view class="text-black">预计收入：<text class="text-bold">{{writeInfo.storeMoney}}元</text></view>
				</view>
			</view>
		</view>

		<button v-if="writeInfo" class="cu-btn block bg-black margin-tb lg margin-lr-sm" @click="updateWrite">确认核销</button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			writeInfo:'',
			verification:''
		};
	},
	computed: {
		
	},
	methods: {
		updateWrite(){
			this.$u.adminApi.updateWrite({
				verification:this.verification
			}).then(res=>{
				if(res.code===200){
					this.$Toast(res.message,'success',1500,()=>{
						uni.navigateBack()
					})
				}else{
					this.$textToast(res.message)
				}
			})
		}
	},
	onLoad(option) {
		this.verification=option.verification
		this.$u.adminApi.getWriteInfo({
			verification:option.verification,
			// verification:'20210826021944927',
			// storeId:9
			storeId:this.vuex_bussinessId
		}).then(res=>{
			if(res.code===200){
				this.writeInfo=res.data
			}
			if(res.code===2001){
				uni.showToast({
					title:res.message,
					icon:'none'
				})
				this.timer=setTimeout(()=>{
					uni.navigateBack()
				},1500)
			}
		})
	},
	onUnload() {
		clearTimeout(this.timer)
	}
};
</script>

<style>
.cu-form-group .title {
	min-width: calc(4em + 15px);
}
</style>
